<?php
/**
 * Created by PhpStorm.
 * User: chenzhitao
 * Date: 2018/3/20
 * Time: 上午9:38
 */

namespace app\index\controller;



use app\index\model\Dist;
use app\index\model\SubCategory;
use app\index\service\CategoryService;
use app\index\service\CompanyService;
use app\index\service\UrlService;
use think\Controller;
use app\index\model\Company as companyModel;

class Company extends BaseController
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index($options, $page)
    {
        if($options){
            $option_array = explode("g",$options);
            $staId=$option_array[0];
            $id = $option_array[1];
            $idCity = $option_array[2];
        }else{
            $staId = 'multi';
            $id = 0;
            $idCity = 0;
        }

        if($page == null){
            $page = 1;
        }

        if($staId == null){
            $staId = 'multi';
        }
        if($id == null){
            $id = 0;
        }
        if($idCity == null){
            $idCity = 0;
        }
        if($page != 1){
            $pagetext = '第'.$page.'页';
        }else{
            $pagetext = '';
        }
        $url_list = UrlService::getIndexThirdUrlList();
        $this->assign("thirdurl_list",$url_list);
        $category_list = CategoryService::getSupCategoryList();
        $company_list = CompanyService::getCompanyList($page);
        $rec_list = CompanyService::getIndexCompanyList();
        $this->assign("company_list",$company_list);
        $this->assign("rec_list",$rec_list);
        $this->assign("category_list",$category_list);
        $this->assign("idIndex","3");
        $this->fetch("public/header");
        $this->fetch("public/footer");

        $category_name = SubCategory::getCategoryNameById($id);
        $city_name = Dist::getDistNameById($idCity);

        return $this->fetch("companyList",["staId"=>$staId, "id"=>$id, "idCity"=>$idCity ,"idIndex" => "3","category_name"=>$category_name,"city_name"=>$city_name,"page"=>$page,"pagetext"=>$pagetext]);
    }
    public function getDeitail($id){
        $seoInfo = companyModel::getSeoInfoById($id);
        $title = $seoInfo['title'];
        $desc = $seoInfo['desc'];
        $url_list = UrlService::getIndexThirdUrlList();
        $category_list = CategoryService::getSupCategoryList();
        $company_detail = CompanyService::getCompanyDetail($id);
        $this->assign("company_detail",$company_detail);
        $this->assign("thirdurl_list",$url_list);
        $this->assign("category_list",$category_list);
        return $this->fetch("companyDetail",["id"=>$id,"title"=>$title,"desc"=>$desc]);
    }
    
    public function getIntroduce($id){
        $seoInfo = companyModel::getSeoInfoById($id);
        $title = $seoInfo['title'];
        $desc = $seoInfo['desc'];
        $url_list = UrlService::getIndexThirdUrlList();
        $this->assign("thirdurl_list",$url_list);
        $company_detail = CompanyService::getCompanyDetail($id);
        $this->assign("company_detail",$company_detail);
        return $this->fetch("companyDetailIntro",["id"=>$id,"title"=>$title,"desc"=>$desc]);
    }
    
    public function getCompCase($id){
        $seoInfo = companyModel::getSeoInfoById($id);
        $url_list = UrlService::getIndexThirdUrlList();
        $this->assign("thirdurl_list",$url_list);
        $title = $seoInfo['title'];
        $desc = $seoInfo['desc'];
        $company_detail = CompanyService::getCompanyDetail($id);
        $this->assign("company_detail",$company_detail);
        return $this->fetch("companyDetailAnli",["id"=>$id,"title"=>$title,"desc"=>$desc]);
    }
    
    public function getCompElite($id){
        $seoInfo = companyModel::getSeoInfoById($id);
        $title = $seoInfo['title'];
        $desc = $seoInfo['desc'];
        $url_list = UrlService::getIndexThirdUrlList();
        $this->assign("thirdurl_list",$url_list);
        $company_detail = CompanyService::getCompanyDetail($id);
        $this->assign("company_detail",$company_detail);
        return $this->fetch("companyDetailJing",["id"=>$id,"title"=>$title,"desc"=>$desc]);
    }
   
}